Skip to content

Add an xmlvalidate command#34

Open
djjuhasz wants to merge 2 commits intomainfrom
dev/add-xmlvalidate-cmd
Open

Add an xmlvalidate command#34
djjuhasz wants to merge 2 commits intomainfrom
dev/add-xmlvalidate-cmd

Conversation

@djjuhasz
Copy link
Copy Markdown
Contributor

Add an xmlvalidate command to help testing the functionality from the CLI.

@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 70eb8c2 to 5605d5d Compare October 18, 2024 22:02
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.88%. Comparing base (8ea34d2) to head (5460863).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   81.88%   81.88%           
=======================================
  Files          16       16           
  Lines         436      436           
=======================================
  Hits          357      357           
  Misses         55       55           
  Partials       24       24           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 5605d5d to 3d926ef Compare October 18, 2024 22:06
Add `xmlvalidate/cmd/xmlvalidate.go` to allow running xmlvalidate from
the CLI for testing purposes.
@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 3d926ef to 3d650f4 Compare October 18, 2024 22:08
Copy link
Copy Markdown
Contributor

@jraddaoui jraddaoui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @djjuhasz, not sure if it adds a lot of value, but check my comments below if you find it useful.

Comment thread xmlvalidate/cmd/main.go
XMLFILE Path of the XML file to be validated

OPTIONS:
--xsd PATH Path of an XSD file to validate against
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's required, I'd make it an argument too.

Copy link
Copy Markdown
Contributor Author

@djjuhasz djjuhasz Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it an option for two reasons:

  1. It avoids confusing the order of the XML file path and XSD file path, e.g. xmlvalidate person.xsd people.xml vs. xmlvalidate people.xml person.xsd
  2. It leaves open the option of adding a --dtd option to validate XML against a DTD file instead of an XSD

I think the first reason justifies typing the extra --xsd .

Comment thread xmlvalidate/cmd/main.go
} else {
fmt.Println(out)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recent PRs changed the xmlvalidate activity but didn't reflect those changes in the docs (parameter names, result type, how to use the XMLLintValidator). It would be nice to include a note somewhere in there about this command too, if we really want to include it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! I'll update the docs. 😊

Comment thread xmlvalidate/cmd/main.go
}

// To test: `go run ./cmd --xsd testdata/person.xsd testdata/person_valid.xml`
func main() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to follow https://artefactual.dev/docs/programming-languages/go/main/ and add some tests for this command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, okay. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants